package cn.da.shuai.cool.finance.controller;

import cn.da.shuai.cool.finance.model.CoolBudgetAudit;
import cn.da.shuai.cool.finance.service.ICoolBudgetAuditService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 预算管理审计接口API类
 */
@RestController
@RequestMapping("/api/finance/budget-audit")
@Tag(name = "预算管理审计接口")
public class CoolBudgetAuditController {

    @Autowired
    private ICoolBudgetAuditService budgetAuditService;

    @PostMapping("/record")
    @Operation(summary = "记录预算管理审计")
    public void recordAudit(@RequestBody CoolBudgetAudit audit) {
        budgetAuditService.recordAudit(audit);
    }

    @GetMapping("/history/{budgetId}")
    @Operation(summary = "获取预算管理审计历史记录")
    public List<CoolBudgetAudit> getBudgetAuditHistory(
            @Parameter(description = "预算ID", required = true) @PathVariable Long budgetId) {
        return budgetAuditService.getBudgetAuditHistory(budgetId);
    }

    @GetMapping("/user/{userId}")
    @Operation(summary = "获取用户预算管理审计记录")
    public List<CoolBudgetAudit> getAuditsByUser(
            @Parameter(description = "用户ID", required = true) @PathVariable Long userId) {
        return budgetAuditService.getAuditsByUser(userId);
    }

    @GetMapping("/date-range")
    @Operation(summary = "根据日期范围获取预算管理审计记录")
    public List<CoolBudgetAudit> getAuditsByDateRange(
            @Parameter(description = "开始日期", required = true) @RequestParam String startDate,
            @Parameter(description = "结束日期", required = true) @RequestParam String endDate) {
        return budgetAuditService.getAuditsByDateRange(startDate, endDate);
    }
}